//
//  JuModel.swift
//  JuSwift
//
//  Created by Juvid on 2018/5/10.
//  Copyright © 2018年 Juvid. All rights reserved.
//

import UIKit
import JuFrameWork
//import JuFirstWork
//import JuOcFrame
//import JuSwiftLib
//import JuOcLib
class JuModel: NSObject  {
    
    var juName: String = ""

    
    func juStart()  {
        let juOc = JuObjectC.init()
        juOc.juTest()
        let sring = #"fsdalfjdslk"""""#

        let juOcf = JuOcTest.init()
        let juOcLib = JuOcLib.init()

        let juGuard = JuGuard()
        juGuard.Jutest()

        let blocks = JuBlock.init()
        blocks.testFunc()
        let increment = juBackFunc(sum: 8)
        _ = increment(7)

        let string = NSString();
        JuSubClass.juClass();

        string.juNames();
        string.juTestDelegage()


        juTestClass()

        let juDifferent = JuDifferent.init()

        juDifferent.juLogType()

        guard let clsName = Bundle.main.infoDictionary!["CFBundleExecutable"] else {
            NSLog("命名空间不存在")
            return
        }
        // 2.通过命名空间和类名转换成类
        let cls : AnyClass? = NSClassFromString((clsName as! String) + "." + "ViewController")
        print(String(describing: cls))

        juClass()
        
        let ju_operation = JuOperation.init()
        ju_operation.juStart()

        let ju_generc = JuGeneric.init()
        ju_generc.start()

        let juTruClass = JuMuCls.init()
        juTruClass.juStart()
    }
    func juTestClass()  {
        let ju_lib = JuSubClass.init(name : "调用")
        ju_lib.ju_open = "open"
        ju_lib.ju_public = "public"
        ju_lib.juOpen()
        ju_lib.juPublic()
    }
    ///increment变量是个函数addOne
    /// 函数作为返回值
    func juBackFunc(sum:Int) -> ((Int) -> Int) {
        func addOne(number: Int) -> Int {
            return number + sum
        }
        addOne(number: 15)
        return addOne
    }
    func juClass()  {
        let clsss:AnyClass = self.classForCoder
        let supClass :AnyClass = self.superclass!

        let testPro = JuSubOjc.init(name: "gagaga")

        testPro.juCheckType()

        
        let testCls:AnyClass = testPro.classForCoder
        if testCls == NSObject.classForCoder() {
            NSLog("相同")
        }
        if testCls.superclass() == NSObject.classForCoder() {
            NSLog("相同")
        }

        if testPro.isKind(of: supClass) {
            NSLog("不相同")
        }


        let classType = testCls as? JuSupOjc.Type
        let my = classType?.init(name : "hhh")
        print( String(describing: classType))

        //        let types = type (of: String)
        //        let mys = types.init()

        print( String(describing: testCls))
        print( String(describing: clsss))
        print( String(describing: supClass))
    }
}
